package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TsuggestionDao;
import com.xy.manage.model.Tsuggestion;
import com.xy.manage.service.TsuggestionService;

@Service
@Transactional
public class TsuggestionServiceImpl extends BaseServiceImpl<Tsuggestion> implements
		TsuggestionService {
	private TsuggestionDao tsuggestionDao;

	public TsuggestionServiceImpl(TsuggestionDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tsuggestionDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tsuggestionDao.checkExist("Tsuggestion", paraName, paraValue);
	}

	@Override
	public List<Tsuggestion> getTsuggestion(Map<String, Object> map) {
		return tsuggestionDao.getTsuggestion(map);
	}
	@Override
	public Pagination getTsuggestionByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tsuggestionDao.getTsuggestionByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tsuggestion save(Tsuggestion tsuggestion) {
	//	tsuggestion.setModtime(new Date());
		if(tsuggestion.getSgid()==null){
			//新增
        	return super.save(tsuggestion);
		}else{
			//更新
			Tsuggestion tsuggestion1=tsuggestionDao.get(tsuggestion.getSgid());
			try {
				BeanUtil.copyNotNullProperties(tsuggestion1, tsuggestion);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tsuggestion1);
		}
	}
}